home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj8408.arc
/
RANDOM7.BAS
< prev
next >
Wrap
BASIC Source File
|
1984-05-11
|
836b
|
23 lines
10 ' Program to compute chi square test of uniformity
20 ' of distribution of RND random number generator
30 ' - P. F. Hultquist, 1983
40 DIM COUNT(101) 'Allows for 100 degrees of freedom
50 FOR I = 1 TO 101
60 COUNT(I) = 0 'Zero the count vector
70 NEXT I
80 RANDOMIZE
90 FOR I = 1 TO 1010
100 K = INT(101*RND) + 1 'Compute index of count
110 COUNT(K) = COUNT(K) + 1 'Count the occurrence
120 NEXT I
130 SUM = 0
140 FOR I = 1 TO 101 'Start computing chi square
150 SUM = SUM + (10 - COUNT(I))^2 '10 is the expected number in
160 NEXT I 'each "bin"
170 CHSQ = SUM/10 'Finish computing chi square
180 PRINT CHSQ
190 PRINT : PRINT "Another? (Y/N)";
200 A$ = INKEY$ : IF A$ = "" THEN 200
210 IF A$="Y" OR A$="y" THEN 50
220 END